package zust.se.delicious.vo;

import java.util.LinkedList;
import java.util.List;

public class PageBean {
	private int current;
	private int size;
	private int total;
	private List<String> pages;
	
	public PageBean() {
		current = 1;
		size = 5;
	}

	public int getPageSize() {
		Double a = Math.ceil((double) total / (double) size);
		System.out.println("a=" + a);
		return a.intValue();
	}

	public boolean isPagingFlag() {
		return getPages().size()>1; 
	}

	public List<String> getPages() {
		List<String> pages = new LinkedList<String>();
		int temp;
		temp = current - 1;
		if (temp > 0) {
			pages.add(String.valueOf(temp--));
			if (temp > 0)
				pages.add(String.valueOf(temp));
		}
		pages.add(String.valueOf(current));
		temp = current + 1;
		while (temp <= getPageSize() && pages.size() < 5) {
			pages.add(String.valueOf(temp++));
		}
		
		for (String page : pages) {
			System.out.println(page);
		}
		System.out.println("pageggggggggggg");
		return pages;
	}

	public int getCurrent() {
		return current;
	}

	public void setCurrent(int current) {
		this.current = current;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public String toString() {
		return "current=" + current + "size=" + size + "total" + total;
	}
}
